1 00:00:00,390 --> 00:00:06,050 Hello and welcome to this vigil on where to place javascript. 2 00:00:06,140 --> 00:00:14,910 Could I have a script called can be placed either in my head section or in the body section of this 3 00:00:14,930 --> 00:00:16,530 Tim old code. 4 00:00:16,920 --> 00:00:25,350 Right so this is the hastier email could whitsun javascript from the previous video. 5 00:00:25,830 --> 00:00:26,150 Right. 6 00:00:26,160 --> 00:00:33,960 So you can place javascript either in the header section or any way in the body section. 7 00:00:34,020 --> 00:00:43,200 So I'll tell you I will show you the effects of placing Javascript in the head and also the impact of 8 00:00:43,200 --> 00:00:45,900 placing javascript on the body. 9 00:00:45,900 --> 00:00:54,200 So we'll start with he has said come first so just copy these javascript removed that cut and pasted 10 00:00:54,330 --> 00:01:00,010 into the code section and then save that to the javascript. 11 00:01:00,010 --> 00:01:08,830 Now is in the head section of the TMI document so I'll save that if I run this. 12 00:01:08,880 --> 00:01:14,120 Observe what would happen are lunch in Firefox. 13 00:01:17,010 --> 00:01:23,730 Okay so if he can observe the javascript loads first. 14 00:01:23,890 --> 00:01:33,010 It prevents any other part of the web page loading so windjammers script is placed in the header section. 15 00:01:33,120 --> 00:01:39,200 It will load first before allowing any of the content to load. 16 00:01:39,540 --> 00:01:44,730 So the only way you can get the content to display is by clicking the okay button. 17 00:01:44,760 --> 00:01:48,600 So if I click or kick Be content when not display. 18 00:01:49,070 --> 00:01:51,570 Okay that's the content for the web page. 19 00:01:51,750 --> 00:01:58,500 So this is the effect of placing Javascript in the head section. 20 00:01:58,500 --> 00:01:58,860 All right. 21 00:01:58,860 --> 00:02:07,970 Next I'm gonna copy this same script and place it in the body section. 22 00:02:07,980 --> 00:02:13,310 The best advice is to win place in Javascript in the body. 23 00:02:13,710 --> 00:02:19,080 Body tag is best to place it just before the end. 24 00:02:19,080 --> 00:02:21,240 Body tags will never be the last 25 00:02:23,910 --> 00:02:27,520 item you place just before disclosing body tags. 26 00:02:27,600 --> 00:02:34,500 Best place recommended took place for javascript because that way it doesn't prevent the page from load 27 00:02:34,500 --> 00:02:35,000 it. 28 00:02:35,340 --> 00:02:48,750 So if I saved that and run it are wanting Firefox all right he can see the pages look the last bartholdi 29 00:02:48,780 --> 00:02:56,550 page content higher log jam a script and then this is a javascript and just click OK and the rest of 30 00:02:56,550 --> 00:02:58,830 the page shows up. 31 00:02:58,830 --> 00:03:07,380 So the advantage of placing javascript at the bottom just before the close in body tag is that it lets 32 00:03:07,380 --> 00:03:15,450 the content on the page display without interfering with it whereas placing Javascript in the head section 33 00:03:16,050 --> 00:03:22,350 prevents the content from loading and load sajjad script first. 34 00:03:22,710 --> 00:03:32,720 In this video I give a demo on place in the javascript code in the head section of the hastier mail 35 00:03:32,730 --> 00:03:38,960 document I saw in the body section of the hysteria document. 36 00:03:39,080 --> 00:03:45,790 It's always best to place the javascript just before you close embody attack. 37 00:03:45,990 --> 00:03:51,150 That way it lets your content load without interference. 38 00:03:51,150 --> 00:03:53,220 I hope the video has been helpful. 39 00:03:53,460 --> 00:03:56,390 Thank you so much for watching and bye for now.